﻿namespace LxCore
{
    public struct PairMatrix
    {
        public double a11;
        public double a12;
        public double a14;
        public double b1;
        public double a21;
        public double a22;
        public double a23;
        public double a24;
        public double b2;
        public double a31;
        public double a32;
        public double a33;
        public double a34;
        public double b3;
        public double a41;
        public double a43;
        public double a44;
        public double b4;
        public void Eliminate_a23a32()
        {
            double elifactor = a23 / a33;
            double a22future = a22 - elifactor * a32;
            a24 = -elifactor * a34;
            double b2future = b2 - elifactor * b3;

            elifactor = a32 / a22;
            a31 = -elifactor * a21;
            a33 -= elifactor * a23;
            b3 -= elifactor * b2;

            a22 = a22future;
            b2 = b2future;

            a23 = 0;
            a32 = 0;
        }
        public void Eliminate_a12a43()
        {
            double elifactor = a12 / a22;
            a11 -= elifactor * a21;
            a14 = -elifactor * a24;
            b1 -= elifactor * b2;

            elifactor = a43 / a33;
            a41 = -elifactor * a31;
            a44 -= elifactor * a34;
            b4 -= elifactor * b3;
        }
        //public void Relax23(double relaxFactor, double x2, double x3)
        //{
        //    double relax1 = 1 - relaxFactor;
        //    double relaxFactorReverse = 1 / relaxFactor;
        //    a22 *= relaxFactorReverse;
        //    b2 += relax1 * a22 * x2;
        //    a33 *= relaxFactorReverse;
        //    b3 += relax1 * a33 * x3;
        //}
    }
}